home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / PacMan / Maze.h < prev    next >
Encoding:
Text File  |  1992-06-27  |  2.8 KB  |  81 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. // Takes care of the maze;  it knows all the maze templates, parses the "mazes"
  5. // file in the .app wrapper, and knows which dots have been eaten.
  6.  
  7. #import <objc/Object.h>
  8. #import <appkit/graphics.h> 
  9.  
  10. // how many mazes are available
  11. #define MAZES 6
  12.  
  13. // image size in pixels; they are square
  14. #define GHOST_SIZE        16
  15. #define PER_ROW            6    // number of maze blocks per row in Maze.tiff
  16.  
  17. // size of maze in # of images (blocks)
  18. #define BLOCK_WIDTH        21
  19. #define BLOCK_HEIGHT    16
  20.  
  21. // the view _must_ have these dimensions:
  22. #define WIN_WIDTH        GHOST_SIZE * BLOCK_WIDTH
  23. #define WIN_HEIGHT        GHOST_SIZE * BLOCK_HEIGHT
  24.  
  25. // max # of these things:
  26. #define MAX_GHOSTS        4
  27. #define MAX_POWER_DOTS    4
  28.  
  29. // useful macros:
  30. #define sgn(x)        ((x) ? (((x) > 0) ? 1 : -1) : 0)
  31. #define abs(x)        (((x) < 0) ? -(x) : (x))
  32.  
  33. // point values
  34. #define DOTPOINTS 10
  35. #define POWERDOTPOINTS 50
  36.  
  37. // maze parts (indices)
  38. #define GHDOOR    5
  39. #define PLAYER    7
  40. #define GHOST    10
  41. #define EMPTY    8
  42. #define DOT        28
  43. #define POWER    29
  44.  
  45. @interface Maze:Object
  46. {
  47.     id   mazeParts;    // NXImage with Maze.tiff in it.
  48.     int  mazeNum;    // which maze is currently displayed; between 0 and MAZES-1
  49.     char mazes[MAZES][BLOCK_WIDTH][BLOCK_HEIGHT];    // holds base maze data
  50.     char maze[BLOCK_WIDTH][BLOCK_HEIGHT];    // holds working copy of maze data
  51.     int  power[MAX_POWER_DOTS * 2];        // locations of power dots
  52.     int  ghosts[MAX_GHOSTS * 2];        // starting ghost locations
  53.     int  player[2];                        // starting player/fruit position
  54.     int  door[2];                        // ghost chamber door position
  55.     int  dots;                            // number of dots left in current maze
  56.     int  dotx, doty;                    // (x, y) of last dot eaten
  57.     BOOL powerDotShown;                    // whether or not to draw a power dot
  58.     BOOL visibleMaze;                    // whether or not to draw the maze
  59. }
  60.  
  61. - init;
  62. - render:(NXRect *)rect at:(NXPoint *)pos;     // used to render
  63.     // lockfocus in the view where it's drawn first.
  64. - makeMaze:(int)num;                // loads maze into working array and sets
  65.                                     // up ghost/power dot/player locations
  66. - playerPosition:(int *)x :(int *)y;    // return x, y of player/fruit
  67. - doorPosition:(int *)x :(int *)y;    // return x, y of door to ghost chamber
  68. - (const int *)powerDot;            // return pointer to power array
  69. - (const int *)ghosts;                // return pointer to ghosts array
  70. - (BOOL)powerDotAt:(int)x :(int)y;    // return YES if power dot in block
  71. - (BOOL)eatDotAt:(int)x :(int)y;    // return YES if OK, NO if no dot was there
  72. - (int)dots;                        // return the number of dots left in maze
  73. - (BOOL)playerWall:(float)x :(float)y;    // YES if player can't be in block
  74. - (BOOL)monsterWall:(float)x :(float)y;    // YES if ghost can't be in block
  75. - blinkPowerDot;                    // toggle ON/OFF state of power dots
  76. - lastDot:(int *)xx :(int *)yy;        // returns (x,y) of last dot eaten
  77. - visible:(BOOL)flag;                // used to tell us if the maze is visible
  78. - (BOOL)isVisible;                    // used to tell others if maze is visible
  79.  
  80. @end
  81.